wx.cloud.init();
let db = wx.cloud.database()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[
      {_id: "429d17da6045bdae01383909269bb265", name: "饿了吗『 大额 』红包通道", type: 1},
      {_id: "429d17da6045bdae0138390a6cbace60", name: "饿了吗普通红包通道", type: 1},
      {_id: "429d17da6045bdae0138390b3550677f", name: "美团外卖『 大额 』红包通道", type: 2},
      {_id: "429d17da6045bdae0138390c12a4330f", name: "美团外卖普通红包通道", type: 2}
    ],
    path:{}
  },
  elemaLink(){
    let that = this
    wx.navigateToMiniProgram({
      appId: 'wxece3a9a4c82f58c9',
      path:that.data.path.elema
    })
  },
  meituanLink(){
    let that = this
    wx.previewImage({
      urls: [that.data.path.meituan],
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    wx.showLoading({
      title:'请稍等...'
    })
    db.collection('path')
    .get({
      success:(e)=>{
        let path = e.data[0]
        that.setData({
          path
        })
      }
    })
    db.collection('list')
    .get({
      success:(e)=>{
        console.log(e)
        let list = e.data
        that.setData({
          list
        })
      }
    })
    setTimeout(function(){
      wx.hideLoading()
    },1000)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let that = this
    return {
      title:'这样点外卖，一年能省一个亿！',
      imageUrl:this.data.path.share?this.data.path.share:'https://7474-tt-izzpq-1305171559.tcb.qcloud.la/share.png?sign=b5480797b50920eeff230712c697b268&t=1615185351'
    }
  },
  onShareTimeline(){
    return {
      title:'这样点外卖，一年能省一个亿！',
      imageUrl:this.data.path.share?this.data.path.share:'https://7474-tt-izzpq-1305171559.tcb.qcloud.la/share.png?sign=b5480797b50920eeff230712c697b268&t=1615185351',
      query:'pagesA/index/index'
    }
  }
})